package com.liuzu.esys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liuzu.esys.common.LayuiPageVo;
import com.liuzu.esys.mapper.DivisionStaffMapper;
import com.liuzu.esys.pojo.DivisionStaff;
import com.liuzu.esys.service.DivisionStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author : 逸少
 * @time : 2022/7/27
 * @desc :
 */
@Service("/divisionStaffService")
public class DivisionStaffServiceImpl implements DivisionStaffService {
    @Autowired
    private DivisionStaffMapper divisionStaffMapper;


    @Override
    public LayuiPageVo<DivisionStaff> divisionStaffPageData(Map<String, Object> params) {

           //mybatis 的分页插件
        Integer page = Integer.parseInt(params.get("page") + "");
        Integer limit = Integer.parseInt(params.get("limit") + "");
        PageHelper.startPage(page, limit);
        List<DivisionStaff> users = divisionStaffMapper.selectByParams(params);

        //mybatis 的分页数据结构
        PageInfo<DivisionStaff> divisionStaffPageInfo = new PageInfo<>(users);
        //把 mybatis 的分页 数据 封装到 layui 的分页数据中

        LayuiPageVo<DivisionStaff> divisionStaffLayuiPageVo = new LayuiPageVo<>();
        divisionStaffLayuiPageVo .setCode(0);//layui 默认 0 是正确的状态码
        divisionStaffLayuiPageVo .setMsg("分页列表数据");//提示信息
        divisionStaffLayuiPageVo .setCount(divisionStaffPageInfo.getTotal());//总记录数
        divisionStaffLayuiPageVo .setData(divisionStaffPageInfo.getList());//分页的列表数据
        return divisionStaffLayuiPageVo ;
    }

    @Override
    public List<DivisionStaff> DivisionStaffList() {
        return null;
    }

    @Override
    public int divisionStaffDelete(int id) {

        return divisionStaffMapper.divisionStaffDelete(id);
    }

    @Override
    public int divisionStaffUpdate(DivisionStaff divisionStaff) {
        return divisionStaffMapper.divisionStaffUpdate(divisionStaff);
    }

    @Override
    public int addDivisionStaff(DivisionStaff divisionStaff) {
        return divisionStaffMapper.addDivisionStaff(divisionStaff);
    }
}
